Net Stop MSExchangeTransport
Net Stop MSExchangeRPC
Net Stop W3SVC
Net Start W3SVC

$EXDIR="D:\ProcessAttachmentAndSecureText"

Write-Output "Disabling agent"
Disable-TransportAgent -Identity "Process Attachment And Secure Text" -Confirm:$false

Write-Output "Deregistering agent..."
Uninstall-TransportAgent -Identity "Process Attachment And Secure Text" -Confirm:$false

Write-Output "Deleting directories and files..."
Remove-Item $EXDIR\* -Recurse -ErrorAction SilentlyContinue
Remove-Item $EXDIR -Recurse -ErrorAction SilentlyContinue

Net Start MSExchangeRPC
Net Start MSExchangeTransport

Write-Output "Uninstallation complete."


